<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>login</title>
    <style type="text/css">
        .home {
            background-color: #59375A;
            width: 100%;
            height: 100%;
        }

        .home .all {
            width: 50vw;
            height: 40vw;
            margin: 25vw auto;

        }

        .home .all form .formhead {
            background-color: #6D4A70;
            width: 100%;
            height: 4.5vw;

            display: flex;
            align-items: center;
            justify-content: space-between;

        }

        .home .all form .formhead p {
            font-family: "微软雅黑";
            font-size: 1.5vw;

            color: white;
            margin-left: 1.5vw;
        }

        .home .all form .formhead a {
            font-size: 1.5vw;
            font-family: "微软雅黑";
            color: white;

            display: flex;
            align-items: center;
            align-content: space-between;
            margin-right: 1vw;
            user-select: none;
            text-decoration: none;
        }

        .home .all form .formbody {
            background-color: #f2f2f2;
            width: 100%;
            height: 20vw;
            margin-top: 0;
        }

        .home .all form .formbody .input {
            display: flex;
            flex-direction: column;
            align-items: center;

        }

        .home .all form .formbody .input .inputa {
            margin-top: 2vw;
            width: 80%;
            height: 3vw;
            border: none;
            border-radius: 0.4vw;
            align-content: space-between;
            background-image: url("1.png");
            background-repeat: no-repeat;
            background-position-x: 38vw;
            background-position-y: center;
            background-size: 1.5vw;

        }

        .home .all form .formbody .input .inputb {
            margin-top: 1vw;
            width: 80%;
            height: 3vw;
            border: none;
            border-radius: 0.4vw;
            align-content: space-between;
            background-image: url("2.png");
            background-repeat: no-repeat;
            background-position-x: 38vw;
            background-position-y: center;
            background-size: 1.3vw;
        }

        .home .all form .formbody .button {
            display: flex;
            /*justify-content: space-around;*/
            margin-top: 3vw;
        }

        .home .all form .formbody .button button {
            background-color: #59375A;
            color: white;
            font-family: "微软雅黑";
            border-radius: 0.5vw;
            font-size: 1vw;
            width: 11vw;
            height: 3vw;
            margin-left: 5vw;

        }
        .home .all form .formbody .button a{
            color: #666666;
            text-decoration: none;
            margin-left: 1vw;
            line-height: 3vw;;
        }
    </style>
</head>
<body class="home">
<div class="all">
    <form action="chenggong.html" method="get" class="" onsubmit="return checkAll()">
        <div class="formhead">
            <p>Login Form</p>
            <a href="">x</a>
        </div>
        <div class="formbody">
            <div class="input">
                <input class="inputa" type="text" id="name" onblur="checkName()" placeholder="Username">

                <input class="inputb" type="password" id="pwd" placeholder="······" onblur="checkPwd()">
            </div>
            <div class="button">
                <button type="submit">Sign in</button>
                <a href="">Lost your Password ?</a>
            </div>

        </div>
    </form>
</div>
<script type="text/javascript">
    function checkName() {
        var name = document.getElementById("name").value;
        var reg = /^[0-9][a-z0-9A-Z]{5,11}$/;
        if (!reg.test(name)) {
            alert("输入格式有误!用户名不能为空，必须以数字开头，可以包含小写字母和数字6-12位");
            return false;
        }
        return true;
    }

    function checkpwd() {
        var pwd = document.getElementById("pwd").value;
        var reg = /^[0-9a-zA-Z]{6,12}$/;
        if (!reg.test(pwd)) {
            alert("输入格式有误!密码6-12位之间，数字字母的组合");
            return false;
        }
        return true;
    }

    function checkAll() {
        if (checkName() && checkpwd()) {
            return true;
        } else return false;
    }
</script>
</body>
</html>